'''
  http无状态，通过cookie解决
    服务器将cookie放到响应中，浏览器拿到cookie放到浏览器中，自动携带发送到服务器
  set-cookie: NAME=VALUE; Expires/Max-age=DATE;Path=PATH;Domain=DOMAIN_NAME;

  使用cookie库和HTTPCookieProcessor模拟登陆：

'''
# https://open.weixin.qq.com/sns/explorer_broker?appid=wx62ba64796e13f092&redirect_uri=https%3A%2F%2Faccount.xiaomi.com%2Fpass%2Fsns%2Flogin%2Fload&response_type=code&scope=snsapi_userinfo&state=STATE_685333#wechat_redirect
from urllib import request
# http://www.renren.com/880151247/profile


url = 'http://www.renren.com/880151247/profile'
header = {
  'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
  'Cookie':'anonymid=kf7l3yg6-kvuz2v; depovince=GW; _r01_=1; JSESSIONID=abcXCTzkbJqPVhxbN5Esx; ick_login=4971c53b-1a23-41bd-914e-1b844138d2dc; taihe_bi_sdk_uid=51cff2861327f0f92743dfe247bf8c26; taihe_bi_sdk_session=e58774eebc99578235c190b1fcb0a26b; t=43d578e299c079abb0f9c58085ec797d7; societyguester=43d578e299c079abb0f9c58085ec797d7; id=975139027; xnsid=604c4e1d; jebecookies=ac30960c-844b-44e3-8b46-bac680502037|||||; ver=7.0; loginfrom=null; wp_fold=0'
}
req = request.Request(url=url, headers=header)
resp = request.urlopen(req)
with open('python/pachong/renren.html', 'w', encoding='utf-8') as fp:
  fp.write(resp.read().decode('utf-8'))


